package classifier;

import java.util.ArrayList;
import java.util.Hashtable;
import java.util.TreeMap;
import java.util.Map.Entry;

import polarity.Polarity;

import files.TweetManager;
import files.Tweet;

public class ClassifierManager 
{
	static Classifier classifierApple = new Classifier();
	static Classifier classifierGoogle = new Classifier();
	static Classifier classifierMicrosoft = new Classifier();
	static Classifier classifierTwitter = new Classifier();
	static Classifier classifierGeneral = new Classifier();
	static Classifier classifierAppGooMic = new Classifier();
	
	private static Hashtable<String,Classifier> classifierHt = new Hashtable<String,Classifier>();
	
	public static Hashtable<String, Classifier> getClassifierHt() { return classifierHt; }
	
	public static TreeMap<String, Integer> stopWord = new TreeMap<String, Integer>();
	
	private static boolean separeMarkOn = false;
	public static boolean getSepareMarkOn() { return separeMarkOn; }
	public static void setSepareMarkOn(boolean separeMarkOn) { ClassifierManager.separeMarkOn = separeMarkOn; }
	
	/**
         * Constructeur
         */
	private ClassifierManager() { }
	
        /**
         * Initialise les classifieurs
         */
	public static void init() 
	{		
		if ( separeMarkOn == true )
		{
			classifierHt.put("apple", classifierApple);
			classifierHt.put("google", classifierGoogle);
			classifierHt.put("microsoft", classifierMicrosoft);
			classifierHt.put("twitter", classifierTwitter);
		}
		classifierHt.put("general", classifierGeneral);
		
	}
	
        /**
         * Set le tweet a tester
         * @param tweetTest tweet a tester
         */
	public static void setTweetTestClassifier(Tweet tweetTest)
	{
		if ( separeMarkOn == false ) tweetTest.setClassifierMark(classifierHt.get("general"));
		else	tweetTest.setClassifierMark(classifierHt.get(tweetTest.getMark()));
	}
	
        /**
         * Ajoute le tweet a l'entrainement
         * @param tweetTrain tweet a ajouter
         */
	public static void addTweetTrain(Tweet tweetTrain)
	{
		
		if ( separeMarkOn == false )
		{
			tweetTrain.setMark("general");
			TweetManager.addTweetTrain(tweetTrain);
			classifierHt.get(tweetTrain.getMark()).addTweetTrain(tweetTrain);
			
			tweetTrain.setClassifierMark(classifierHt.get(tweetTrain.getMark()));
			
		}
		else
		{
			TweetManager.addTweetTrain(tweetTrain);
			classifierGeneral.addTweetTrain(tweetTrain);
			classifierHt.get(tweetTrain.getMark()).addTweetTrain(tweetTrain);
			tweetTrain.setClassifierMark(classifierHt.get(tweetTrain.getMark()));
		}
	
		
	}
	
        /**
         * Renvoie la liste des stop words
         * @return 
         */
	public static TreeMap<String, Integer> getStopWord() { return stopWord; }
	
        /**
         * Modifie la liste des stop words
         * @param stopWord nouvelle liste
         */
	public static void setStopWord(TreeMap<String, Integer> stopWord) { ClassifierManager.stopWord = stopWord;}
	
	
	
//	public static void printStopWord() 
//	{ 
//		for(Entry<String, Integer> set : stopWord.entrySet() )
//		{
//			System.out.println(set.getKey());
//		}
//	}

}
